package com.example.yin.service.impl;

import com.example.yin.dao.ArticleCommentMapper;
import com.example.yin.dao.ArticleMapper;
import com.example.yin.domain.Article;
import com.example.yin.domain.ArticleComment;
import com.example.yin.service.ArticleCommentService;
import com.example.yin.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author
 * @description
 * @createDate 2023/6/26
 */

@Service
public class ArticleCommentServiceImpl implements ArticleCommentService {

    @Autowired
    ArticleCommentMapper articleCommentMapper;

    @Override
    public boolean add(ArticleComment articleComment) {
        int insert = articleCommentMapper.insert(articleComment);
        if (insert > 0){
            return true;
        }
        return false;
    }

    @Override
    public boolean delete(Integer id) {
        int delete = articleCommentMapper.delete(id);
        if (delete > 0){
            return true;
        }
        return false;
    }

    @Override
    public boolean deleteByCommentId(Integer id) {
        int delete = articleCommentMapper.deleteByCommentId(id);
        if (delete > 0){
            return true;
        }
        return false;
    }

    @Override
    public boolean update(ArticleComment articleComment) {
        int i = articleCommentMapper.updateByPrimaryKey(articleComment);
        if (i > 0){
            return true;
        }
        return false;
    }

    @Override
    public List<ArticleComment> getList(ArticleComment articleComment) {
        List<ArticleComment> list = articleCommentMapper.getList(articleComment);
        if (list != null){
            return list;
        }
        return null;
    }
}
